﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Admin
{
    public partial class Logout : BaseCommon.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Session.Abandon();
            HttpContext.Current.Session.Clear();

            DateTime cookieDate = DateTime.Now.AddDays(-1);
            string cookieDomain = BaseData.UI.PageContext.GetConfig("Domain");

            //userName
            System.Web.HttpContext.Current.Response.Cookies["loginname"].Value = "";
            System.Web.HttpContext.Current.Response.Cookies["loginname"].Domain = cookieDomain;
            HttpContext.Current.Response.Cookies["loginusername"].Expires = cookieDate;
            //userID
            System.Web.HttpContext.Current.Response.Cookies["loginid"].Value = "";
            System.Web.HttpContext.Current.Response.Cookies["loginid"].Domain = cookieDomain;
            HttpContext.Current.Response.Cookies["loginid"].Expires = cookieDate;
            //password
            System.Web.HttpContext.Current.Response.Cookies["loginpassword"].Value = "";
            System.Web.HttpContext.Current.Response.Cookies["loginpassword"].Domain = cookieDomain;
            HttpContext.Current.Response.Cookies["loginpassword"].Expires = cookieDate;
            //写userType
            HttpContext.Current.Response.Cookies["usertype"].Value = "";
            HttpContext.Current.Response.Cookies["usertype"].Domain = cookieDomain;
            HttpContext.Current.Response.Cookies["usertype"].Expires = cookieDate;
            //validation
            System.Web.HttpContext.Current.Response.Cookies["loginvalidation"].Value = "";
            System.Web.HttpContext.Current.Response.Cookies["loginvalidation"].Domain = cookieDomain;
            HttpContext.Current.Response.Cookies["loginvalidation"].Expires = cookieDate;
            //记录日志
            TaxBiz.Log.LoginLogBiz.Add(UserLogin, 0);

            string redirecturl = "/Admin/Login.aspx";
            Response.Redirect(redirecturl);
        }
    }
}